'use strict';

const Controller = require('egg').Controller;
const util = require("util");

/**
 * 仪器控制类
 */
class equipmentController extends Controller {
  //首页
  async index() {
    const { ctx } = this;
    ctx.body = '/info  查看所有设备列表i';
  }
  //查询所有仪器信息的方法
  async info() {
    const ctx = this.ctx;
    const result = await ctx.service.equipmentService.findall();
    ctx.body = util.inspect(result);
    console.log('查询完成！');
    return result;
    
  }

  //根据id修改仪器信息
  async updatebyid() {
    const ctx = this.ctx;
    const result = await ctx.service.equipmentService.updateById();
    ctx.body = util.inspect(result);
    console.log('修改成功！');
  }

  //新增仪器
  async insertequip() {
    const ctx = this.ctx;
    const result = await ctx.service.equipmentService.insertEquip();
    ctx.body = util.inspect(result);
    console.log('新增成功！');
  }
  //根据id删除仪器
  async deletebyid() {
    const ctx = this.ctx;
    const result = await ctx.service.equipmentService.deleteById();
    ctx.body = util.inspect('删除完成！');
    console.log('删除完成！');
  }
}
module.exports = equipmentController;
